<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>商家登录</title>
    <link href="../css/Hui.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body { background: url(../image/login_bg.jpg) no-repeat left top; background-size: cover; }
    </style>
</head>
<body class="H-height-100-percent H-box-sizing-border-box H-overflow-hidden">
    <div class="fix">
        <div class="H-horizontal-center H-padding-vertical-both-25">
            <div class="H-text-align-center">
                <img src="../image/logo.png" class="H-border-radius-12 H-margin-vertical-top-10" style="width:80px;height:80px;" />
                <div class="H-font-size-18">商家登录</div>
            </div>
        </div>

        <div class="H-border-vertical-top-after H-margin-vertical-top-10">
            <div class="H-flexbox-horizontal  H-border-vertical-bottom-margin-both-10-after">
                <span class="H-icon H-vertical-middle H-padding-horizontal-left-10">
                    <i class="H-iconfont H-icon-phone H-font-size-18 H-vertical-middle H-theme-font-color-999"></i></span>
                <input id="userId" type="text" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-16 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-15 H-theme-background-color-transparent" placeholder="请输入手机号码" />
            </div>
            <div class="H-flexbox-horizontal H-border-vertical-bottom-after">
                <span class="H-icon H-vertical-middle H-padding-horizontal-left-10">
                    <i class="H-iconfont H-icon-lock H-font-size-18 H-vertical-middle H-theme-font-color-999"></i></span>
                <input id="passWord" type="password" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-16 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-15 H-theme-background-color-transparent" placeholder="请输入登录密码" />
            </div>
            <div class="H-padding-15 H-margin-vertical-top-10">
                <button class="H-button H-width-100-percent  H-font-size-15 H-outline-none
                H-padding-vertical-both-15 H-padding-horizontal-both-20 H-theme-background-color9
                H-theme-font-color-white H-theme-border-color9 H-theme-border-color9-click
                H-theme-background-color9-click H-theme-font-color9-click H-border-radius-3" id="loginBtn">登录</button>
            </div>
        </div>
    </div>
    <div class="H-padding-vertical-bottom-10"></div>

    <script src="../script/H.js" type="text/javascript"></script>
    <script src="../script/jquery-3.7.1.min.js" type="text/javascript"></script>
    <script src="../script/md5.js" type="text/javascript"></script>
    <script src="../api.js" type="text/javascript"></script>
    <script type="text/javascript">


        $('#loginBtn').click(function () {
            login();
        });

        function login() {
            var username = $('#userId').val();
            var password = $('#passWord').val();

            $.ajax({
                type : "post",
                url : '/app/loginV1',
                contentType:'application/json;charset=utf-8',
                dataType : "json",
                data : JSON.stringify({
                    username: username,
                    password: password
                }),
                async : true,
                success : function(json){
                    debugger
                    if(json.code == 0){
                        var user = json.user;
                        var userId = json.user.userId;
                        localStorage.setItem("user", user)
                        localStorage.setItem("userId", userId)
                        localStorage.setItem("username", user.username)
                        if(userId === 1){
                            H.openWin('table_head', '/app/adminindex');
                        }else{
                            H.openWin('table_head', '/app/merchantindex');
                        }

                    }else{
                        alert(json.msg);
                    }
                },

            });

        }

    </script>
</body>
</html>